<?php
namespace Home\Model;
use Think\Model\RelationModel;
class OrderModel extends RelationModel{
	protected $_link = array(
		'OrderDetail'	=> array(
				'mapping_type'  => self::HAS_MANY,
				'class_name'    => 'OrderDetail',
				'foreign_key'   => 'oid',
				'mapping_name'  => 'detail',
				'mapping_order' => 'id desc',
		),
			
	);
	protected $_auto 	=array(
			array('verify_code','getVerifyCode',self::MODEL_INSERT,'callback'),
			array('cdate','getCdate',self::MODEL_INSERT,'callback'),
			array('ctime','getCtime',self::MODEL_INSERT,'callback'),
			array('id','getId',self::MODEL_INSERT,'callback') , // 对id字段在新增的时候自动生成一个ID
	);
	function getId(){
		$util = A('Util');
		return  'P'.$util->getId();//生成用户ID
	}
	function getCtime(){
		return date('H:i:s');
	}
	function getCdate(){
		return date('Y-m-d');
	}
	function getVerifyCode(){
		return uniqid();
	}
}